import { _decorator, Component, Node, Label, color } from 'cc';
import { BaseView } from '../../../../scripts/libs/rxjs/cc3/BaseView';
import { Sprite } from 'cc';
import { ReactiveNumber } from '../../../../scripts/libs/rxjs/cc3/ReactiveNumber';
import { Colors } from '../../game/basic';
import { MergeASAP } from '../../../../scripts/libs/rxjs/cc3/Merge';
import { ReactiveBoolean } from '../../../../scripts/libs/rxjs/cc3/ReactiveBoolean';
import { ReactiveProperty } from '../../../../scripts/libs/rxjs/cc3/ReactiveProperty';
const { ccclass, property, executeInEditMode } = _decorator;

@ccclass('EditorObstacle')
@executeInEditMode
export class EditorObstacle extends BaseView {

    @property(Label)
    infoLabel: Label = null;

    posId = ReactiveProperty.Create<number>(null);

    obstacleId = ReactiveProperty.Create<number>(null);

    useObserves() {
        return [
            MergeASAP(this.posId, this.obstacleId).subscribe(this.refresh.bind(this))
        ];
    }

    refresh() {
        let infoText = `Obstacle #${this.obstacleId.value}`;
        infoText += `\nP:${this.posId.value}`;
        this.infoLabel.string = infoText;
    }

}

